package cn.boot.entity.main;

import static javax.persistence.GenerationType.IDENTITY;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import util.FD;

@Entity
@Table(name = "t_user")
public class SimpleUser implements Serializable {
	private static final long	serialVersionUID	= 3791310546257137126L;
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private Integer						id;
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "userID")
	private User							user;
	private String						type;
	@FD("用户")
	@Transient
	private String						fname;
	private String						photo;

	public String getPhoto() {
		return photo;
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}

	@Transient
	public String getFname() {
		return user.getFname();
	}

	public void setFname(String fname) {
		this.fname = fname;
	}

	@Transient
	public String getRole() {
		if (type != null && !"".equals(type.trim())) {
			return type;
		}
		return "用户";
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public SimpleUser() {
	}

	public Integer getId() {
		return this.id;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public void setId(Integer id) {
		this.id = id;
	}

}